<%@page import="tianqi.entity.UserY"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	System.out.println("basePath: "+basePath);
	
	
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>优个网</title>
		<meta charset="utf-8">
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/sendMail.css">
		<link href="css/bootstrap.min.css" rel="stylesheet">
    	<script type="text/javascript" charset="utf-8" src="js/jquery-1.11.3.js"></script>
    	<script type="text/javascript" charset="utf-8" src="js/bootstrap.min.js"></script>
	</head>
<body>
	<div class="container clear" style="width:1211px;margin:0 auto;">
		<div class="col-md-5 col-md-offset-4">
						<h1 style="color:#FFF;">田奇 - 邮件发送系统</h1>
		</div>
		<div id="yx1" class="col-md-12 clear ">
			<h3 id="h3" class="lf hh3" style="color:#fff;">发件人:</h3>
			<div id="sjer" class="lf" title="发件人邮箱账号">${email!=null?email.email:'' }</div>
		</div>
		<div id="yx" class="col-md-12 clear">
			<h3 id="h3" class="lf hh3" style="color:#fff;">收件人:</h3>
			<div id="sj" class="lf sj" title="发给多人时地址请以分号隔开"  contenteditable="true"></div>
		</div>
		<div id="yx" class="col-md-12 clear">
			<h3 id="h3" class="lf hh3" style="color:#fff;">主题:</h3>
			<div id="zt" class="lf sj" title="主题"  contenteditable="true"></div>
		</div>
		
	</div>
	<div id="contain" class="clear">
	<div id="div3" style="height:560px;" class="col-md-12"></div>
	
	
	</div>
	<div id="footer" class="col-md-12 clear1">
		<div class="btn btn-primary" id="sendEmail">发送</div>
	</div>
	
	
	<c:choose>
   		<c:when test="${mail=='0' }"> 
   			<div id="tan_top" class="container">
			<div class="col-md-4 col-md-offset-4"><h1>请注册邮箱</h1></div>
			<form class="form-horizontal col-md-12" action="${pageContext.request.contextPath}/registEmail.tq">
  				<div class="form-group">
    				<label for="inputEmail3" class="col-sm-2 control-label">邮箱:</label>
    				<div class="col-sm-10">
      				<input name="email" type="email" class="form-control" id="inputEmail3" placeholder="Email"">
    			</div>
 		 </div>
  				<div class="form-group">
    			<label for="inputPassword3" class="col-sm-2 control-label">密码:</label>
    			<div class="col-sm-10">
      			<input name="epwd" type="password" class="form-control" id="inputPassword3" placeholder="密码:">
    			</div>
  			</div>
  
  				<div class="form-group">
   				 <div class="col-sm-offset-2 col-sm-10">
     		 <button type="submit" class="btn btn-primary">提交</button>
     		 <a href="${pageContext.request.contextPath}/youge.tq" class="btn btn-primary" style="margin-left:15px;">取消</a>
    		</div>
  			</div>
		</form>
		
		 
	</div>
   			
   		</c:when>
   		
	</c:choose>
	
	
	 <script type="text/javascript" src="js/wangEditor.min.js"></script>
    <script type="text/javascript">
        var E = window.wangEditor
        var editor2 = new E('#div3')
        
        editor2.customConfig.uploadImgShowBase64 = true ;
        editor2.create();
        $('#div3').children('div').eq(1).css({height:"100%",backgroundColor:'rgba(0,0,0,0.5)'});
        
        $('#div3').children('div').eq(1).children('div').css({color:'#FFFFFF'});
        
        
        $('#sendEmail').click(function(){
        	console.log(editor2.txt.html());
        	alert();
        	 $.ajax({
     		    type:"post",
     		    url:"${pageContext.request.contextPath}/SendEmail.tq",
     		    data:{
     		    	toaddress:$('#sj').html().trim(),
     		    	subJect:$('#zt').html().trim(),
     		    	content:editor2.txt.html()
     		    },
     		    success:function(res){
     		      console.log(res);
     		      if(res == "ok"){
     		        alert("您的邮件发送成功！！！");
     		      }else if(res == "nocan"){
     		    	 alert("您的邮件服务器不被支持");
     		      }else if(res == "sessionOut"){
     		    	 alert("会话过期  请重新登录");
     		      }
     		    },
     		    error:function(res){
     		      alert(res);
     		    }
     		  })
     		});
        
        
    </script>
</body>
</html>